﻿using YasharEl.Infrastructure.ObjectFactory;

namespace YasharEl.Infrastructure.EntityModel.Specifications
{
    public class DependencyResolverSpecificationLocator : ISpecificationLocator
    {
        #region Protected Properties

        protected IDependencyResolver DependencyResolver { get; private set; }

        #endregion

        #region Constructors

        public DependencyResolverSpecificationLocator(IDependencyResolver dependencyResolver)
        {
            DependencyResolver = dependencyResolver;
        }

        #endregion

        #region ISpecificationLocator Implementations

        public TSpecification Resolve<TSpecification, TEntity, TIdentity>()
            where TSpecification : ISpecification<TEntity, TIdentity>
            where TEntity : class, IGenericEntity<TIdentity>
        {
            return DependencyResolver.Resolve<TSpecification>();
        }

        #endregion
    }
}
